using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.Transactions;
using HengTong.Model;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using TiaoTaoHelper.Wtm.Workflow;
using Microsoft.Extensions.DependencyInjection;
using HengTong.Model.Db;
using HengTong.Model.Db.System;
using HengTong.Model.Services;
using TiaoTaoHelper.Models;
using TiaoTaoHelper.Wtm.Models;


namespace HengTong.ViewModel.Common.SysSealVms
{
    public partial class SysSealVm : CrudVm<SysSeal>
    {

        public SysSealVm()
        {
            SetInclude(x => x.Org);
            SetInclude(x => x.Group);
        }

        protected override void InitVM()
        {
        }

        public override async Task DoAddAsync()
        {
            if (Entity is IBasePoco poco)
            {
                poco.CreateBy = Wtm.LoginUserInfo?.ITCode;
                poco.UpdateBy = Wtm.LoginUserInfo?.ITCode;
                poco.CreateTime = DateTime.Now;
                poco.UpdateTime = DateTime.Now;
            }
            await base.DoAddAsync();
        }

        public override async Task DoEditAsync(bool updateAllFields = false)
        {
            if (Entity is IBasePoco poco)
            {
                poco.UpdateBy = Wtm.LoginUserInfo?.ITCode;
                poco.UpdateTime = DateTime.Now;
            }
            await base.DoEditAsync(updateAllFields);
        }

    }
}
